package Threads;

import java.io.IOError;
import java.io.IOException;
import java.net.ServerSocket;
import java.net.Socket;
import java.util.Hashtable;
import java.util.concurrent.BlockingDeque;
import java.util.concurrent.BlockingQueue;

import Structs.Log;
import Structs.Msg_broad;
import Structs.Msg_rsp;

public class S_TCP_Starter implements Runnable {

	private int port_clients;
	private Hashtable Clients;
	private Hashtable Tasks;
	private Hashtable OnlineClients;
	private BlockingQueue <Thread> GrimReaper;
	private BlockingQueue<Msg_broad> Broadcast;
	private BlockingDeque<Log> log;
	private Thread Mylife;
	
	public S_TCP_Starter(
						int port,
						Hashtable Client,
						Hashtable Tasks,
						BlockingQueue GrimReaper,
						BlockingQueue<Msg_broad> requests,
						BlockingDeque<Log> log,
						Hashtable onlineClients) {
		this.port_clients = port;
		this.Clients = Client;
		this.OnlineClients = onlineClients;
		this.Tasks = Tasks;
		this.GrimReaper = GrimReaper;
		this.log = log;
		this.Broadcast = requests;
		this.Mylife = new Thread(this);
		this.Mylife.start();
	}
	
	@Override
	public void run() {
		// TODO Auto-generated method stub
		
		new Thread(new S_TCP_REQ_LISTEN(port_clients, Clients, Tasks, GrimReaper,Broadcast,log,OnlineClients));
		// iniciar thread para ficheiros
		
		
		this.GrimReaper.add(Mylife);
	}

}
